/**
 * 
 */
package com.orcwar.util;

import com.orcwar.engine.OWConstants;

import android.util.DisplayMetrics;

/**
 * Used to keep the screen size in a singleton to prevent recalculating it all the time.
 * @author Callil
 *
 */
public class MetricsUtil {
	private static MetricsUtil instance;

	private static int screenWidth;
	private static int screenHeight;
	private static int gameWindowHeight;
	private static int bottomMenuHeight;
	
	/**
	 * Forbidden constructor
	 */
	private MetricsUtil() {
		// TODO Auto-generated constructor stub
	}
	
	public static synchronized void initialize(DisplayMetrics metrics) {
		screenWidth = metrics.widthPixels;
		screenHeight = metrics.heightPixels;
		bottomMenuHeight = OWConstants.BOTTOM_MENU_HEIGHT;
		gameWindowHeight = screenHeight - bottomMenuHeight;
	}
	
	public static MetricsUtil getInstance() {
		if (instance == null) {
			throw new IllegalStateException("FUCK YOU ! Initialize first");
		}
		return instance;
	}

	
	//*****************//
	// GETTERS/SETTERS //
	
	/**
	 * @return the screenWidth
	 */
	public static int getScreenWidth() {
		return screenWidth;
	}

	/**
	 * @param screenWidth the screenWidth to set
	 */
	public static void setScreenWidth(int screenWidth) {
		MetricsUtil.screenWidth = screenWidth;
	}

	/**
	 * @return the screenHeight
	 */
	public static int getScreenHeight() {
		return screenHeight;
	}

	/**
	 * @param screenHeight the screenHeight to set
	 */
	public static void setScreenHeight(int screenHeight) {
		MetricsUtil.screenHeight = screenHeight;
	}

	/**
	 * @return the gameWindowHeight
	 */
	public static int getGameWindowHeight() {
		return gameWindowHeight;
	}

	/**
	 * @param gameWindowHeight the gameWindowHeight to set
	 */
	public static void setGameWindowHeight(int gameWindowHeight) {
		MetricsUtil.gameWindowHeight = gameWindowHeight;
	}

	/**
	 * @return the bottomMenuHeight
	 */
	public static int getBottomMenuHeight() {
		return bottomMenuHeight;
	}

	/**
	 * @param bottomMenuHeight the bottomMenuHeight to set
	 */
	public static void setBottomMenuHeight(int bottomMenuHeight) {
		MetricsUtil.bottomMenuHeight = bottomMenuHeight;
	}


	// GETTERS/SETTERS //
	//*****************//
}
